﻿using System;
using Framework.Interface;
using Framework.Manager;
using Framework.UI;
using UnityEngine.UI;

namespace Logic.UI.Loading
{
    public class LoadingView : UIView
    {
        public Slider sldProgress;
        
        private void OnEnable()
        {
            sldProgress.value = 0;
            EventsManager.Instance.Add<TaskProgressArgs>(OnProgress);
        }

        private void OnDisable()
        {
            EventsManager.Instance.Remove<TaskProgressArgs>(OnProgress);
        }

        private void OnProgress(IListener args)
        {
            if (args is TaskProgressArgs)
            {
                sldProgress.value = (args as TaskProgressArgs).progress;
            }
        }
    }
}